package com.emergency.db.dao.item;

import com.emergency.db.domain.item.ItemUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;


import java.util.List;


public interface ItemUserDao extends JpaRepository<ItemUser, Long>, JpaSpecificationExecutor<ItemUser> {
    @Modifying
    @Query("delete  from ItemUser  where item.id=:id ")
    void deleteAllByItem(Long id);

    @Query("select iu from ItemUser iu where item.id=:id ")
    List<ItemUser> findAllByItem(@Param("id") Long id);
}
